<!Doctype> 
<title>DHTML Performance Tip: Shorten Object Chains</title> 
<form method="get"> 
	<input type="button" value='test longRef()' onclick='document.getElementById("long").value = longRef()' /> 
	<input type="text" id='long' value="" size="30" /> <br/>
	<input type="button" value='test shortRef()' onclick='document.getElementById("short").value = shortRef()' /> 
	<input type="text" id='short' size="30" /> 
</form> 
<script type="text/javascript"> 
function longRef() { 
    var t0 = new Date().getTime();    
    var tmp;
    for(var i = 0; i < 10000; i++) {
        tmp = window.document.forms[0].elements[0];
    }
    return new Date().getTime() - t0;
}
 
function shortRef() { 
    var t0 = new Date().getTime();    
    var input0 = window.document.forms[0].elements[0];
    var tmp;
    for(var i = 0; i < 10000; i++) {
        tmp = input0;
    }
    return new Date().getTime() - t0;
}
 
</script> 
